<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
            width: 100px;
            height: 30px;
            background-color: rgb(255, 0, 0);
            margin-bottom: 5px;
        }
    </style>
  </head>
  <body>
    <div id="app">
          <input type="text" v-model="zzz" />
          <button @click="add">增加</button>
        <div id="a">
            <div class="box" v-for="(item,index) in list" :key="index">
              <span>{{item.zzz}}</span>
              <button @click="see(index)">删除</button>
            </div>
          </div>

    </div>
  </body>
  <script src="./vue.js"></script>
  <script>
    const { createApp, ref } = Vue;
    createApp({
      setup() {
        let list = ref([]);
        let zzz = ref("");
        function add() {
            if(zzz.value.trim()==='') return
          list.value.push({ zzz: zzz.value })
          zzz.value = "";
        }
        function see(index) {
          list.value.splice(index, 1);
        }
        return {
          list,
          zzz,
          add,
          see,
        };
      },
    }).mount("#app");
  </script>
</html>
